import request from '@/utils/request'

// 获取入库单列表
export function listItemReceipts(query) {
  return request({
    url: '/ck/receipt/findAll_receipt',
    method: 'post',
    params: query
  })
}

// 获取入库单详情
export function getItemReceiptDetail(recpt_id, params) {
  return request({
    url: '/ck/receipt/findReceipt_id/' + recpt_id,
    method: 'post',
    params: params
  })
}

// 获取采购订单 到货和采购中的订单
export function getListArrived(query) {
  return request({
    url: '/ck/receipt/findOrder_arrived/',
    method: 'post',
    params: query
  })
}

// 新增入库单
export function addItemReceipt(itemReceiptDTO) {
  return request({
    url: '/ck/receipt/addItemReceipt',
    method: 'post',
    data: itemReceiptDTO
  })
}

// 修改入库单
export function updateItemReceipt(data) {
  return request({
    url: '/ck/receipt/update',
    method: 'put',
    data: data
  })
}


// 批量删除入库单
export function batchDeleteItemReceipts(ids) {
  return request({
    url: '/ck/receipt/deleteItemReceiptBatch',
    method: 'post',
    data: ids
  })
}



// 物料退货操作
export function returnItemReceipt(recptId) {
  return request({
    url: '/ck/receipt/return/' + recptId,
    method: 'put'
  })
}



// 获取可用的采购订单列表
export function listAvailablePurchaseOrders(query) {
  return request({
    url: '/ck/receipt/available-orders',
    method: 'get',
    params: query
  })
}

// 根据采购订单ID获取订单详情
export function getPurchaseOrderDetail(poId) {
  return request({
    url: '/ck/receipt/order-detail/' + poId,
    method: 'get'
  })
} 

// 查询采购订单详情 可入库
export function listPurchaseOrderDetails(query) {
  return request({
    url: '/ck/receipt/findAll_po_line/',
    method: 'post',
    params: query
  })
}

// 根据采购订单ID查询采购订单行信息
export function selectRecptLine_feedback(recpt_id) {
  return request({
    url: '/ck/receipt/selectRecptLine_feedback/'+recpt_id,
    method: 'get'
  })
} 

// 提交入库单
export function submitReceipt(recpt_id) {
  return request({
    url: '/ck/receipt/submitReceipt/'+recpt_id,
    method: 'get'
  })
}


// 入库
export function recptStore(query) {
  return request({
    url: '/ck/receipt/recptStore/',
    method: 'post',
    data: query
  })
}



